 <?php
   
            if($responsavelList != null){
        ?>
            <table cellpadding="0" cellspacing="1" border="0" width="100%" id="ds_responsavel" >
                <thead class="ui-widget-header" >
                    <tr style="text-transform: uppercase;">

                        <th>Nome</th>
                        <th>Parentesco</th>
                        <th>Tel. Residencial</th>
                        <th>Tel. Celular</th>
                        <th>Tel. Trabalho</th>
                        <th colspan="2"></th>
                        
                    </tr>
                </thead>
                <tbody>

                    <?php
                    unset($value);
                    foreach ($responsavelList->getResult() as $value) {
                        
                        $parentesco = $this->em->find('models\parentesco',$value->getParentescoCod());

                        $queryFone = $this->em->createQuery('SELECT t FROM models\telefone t WHERE t.responsavelCod = ?1');
                        $queryFone->setParameter(1, $value->getResponsavelCod());
                        
                        unset($telefone);
                        foreach ($queryFone->getResult() as $telefone) {
                            unset($foneFixo);
                            unset($foneCelular);
                            unset($foneTrabalho);
                            if($telefone->getTelefoneTipo() == 1){

                                $foneFixo = $telefone->getTelefoneNumero();

                            } else if($telefone->getTelefoneTipo() == 0){

                                $foneCelular = $telefone->getTelefoneNumero();

                            } else {
                                $foneTrabalho = $telefone->getTelefoneNumero();
                            }

                        }


                    ?>

                    <tr style="background-color:#F6F6F6" id="tr_<?php echo $value->getResponsavelCod(); ?>">

                        <td><div align="center" id="respNome_<?php echo $value->getResponsavelCod(); ?>"><?php echo utf8_encode(@$value->getResponsavelNome()); ?></div></td>
                            <td><div align="center" id="respParentesco_<?php echo $value->getResponsavelCod(); ?>"><?php echo utf8_encode(@$parentesco->getParentescoDescricao()); ?></div></td>
                            <td><div align="center" id="respFoneRes_<?php echo $value->getResponsavelCod(); ?>"><?php echo @$foneFixo; ?></div></td>
                            <td><div align="center" id="respCelular_<?php echo $value->getResponsavelCod(); ?>"><?php echo @$foneCelular; ?></div></td>
                            <td><div align="center" id="respFoneTrabalho_<?php echo $value->getResponsavelCod(); ?>"><?php echo @$foneTrabalho; ?></div></td>
                            <td>
                                <div align="center">
                                    <a href="#" id="lnkview">
                                        <img alt="" src="<?php echo base_url() . 'assets/images/ico_view.png' ?>" border="0" title="Visualizar" onclick="detalharResponsavel('<?= $value->getResponsavelCod() ?>')" width="20" height="20"/>
                                    </a>
                                </div>
                            </td>
                            <td>
                                <div align="center">
                                    <a href="#" id="lnkdelete">
                                        <img alt="" src="<?php echo base_url() . 'assets/images/excluir.png' ?>" border="0" title="Excluir" onclick="excluirResponsavel('<?php echo $value->getResponsavelCod(); ?>')" />
                                    </a>
                                </div>
                            </td>
                         </tr>
                         
                    <?php  } ?>

                </tbody>


            </table>

        <?php } ?>